package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.CcQualityAttribute;
import com.lxmes.business.service.ICcQualityAttributeService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 质量属性表Controller
 * 
 * @author 张志煜
 * @date 2022-11-28
 */
@RestController
@RequestMapping("/business/qualityAttribute")
public class CcQualityAttributeController extends BaseController
{
    @Autowired
    private ICcQualityAttributeService ccQualityAttributeService;

    /**
     * 查询质量属性表列表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityAttribute:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcQualityAttribute ccQualityAttribute)
    {
        startPage();
        List<CcQualityAttribute> list = ccQualityAttributeService.selectCcQualityAttributeList(ccQualityAttribute);
        return getDataTable(list);
    }

    /**
     * 导出质量属性表列表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityAttribute:export')")
    @Log(title = "质量属性表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcQualityAttribute ccQualityAttribute)
    {
        List<CcQualityAttribute> list = ccQualityAttributeService.selectCcQualityAttributeList(ccQualityAttribute);
        ExcelUtil<CcQualityAttribute> util = new ExcelUtil<CcQualityAttribute>(CcQualityAttribute.class);
        util.exportExcel(response, list, "质量属性表数据");
    }

    /**
     * 获取质量属性表详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:qualityAttribute:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ccQualityAttributeService.selectCcQualityAttributeById(id));
    }

    /**
     * 新增质量属性表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityAttribute:add')")
    @Log(title = "质量属性表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcQualityAttribute ccQualityAttribute)
    {
        return toAjax(ccQualityAttributeService.insertCcQualityAttribute(ccQualityAttribute));
    }

    /**
     * 修改质量属性表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityAttribute:edit')")
    @Log(title = "质量属性表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcQualityAttribute ccQualityAttribute)
    {
        return toAjax(ccQualityAttributeService.updateCcQualityAttribute(ccQualityAttribute));
    }

    /**
     * 删除质量属性表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityAttribute:remove')")
    @Log(title = "质量属性表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccQualityAttributeService.deleteCcQualityAttributeByIds(ids));
    }
}
